package cn.com.dhcc.turbo.xian;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import cn.com.dhcc.app.core.util.FileUtil;
import cn.com.dhcc.app.core.util.FreemarkerUtil;
import freemarker.template.TemplateException;

public class CreateConf {

	public static void main1(String[] args) {
		String severB = "<Context docBase=\"F:\\exchtest\\turbo";
		String severA = "\" path=\"/turbo";
		String severE = "\" reloadable=\"false\"/>";
		for (int i = 0; i < 40; i++) {
			System.out.println(severB+(i+1)+severA+(i+1)+severE);
			
		}
	}
	public static void main2(String[] args) {
		String db ="create user TURBO";
		String db2 = " default tablespace TBS_TURBO identified by turbo;";
		String db3 = " grant connect, dba ,resource to TURBO";
			for (int i = 0; i < 40; i++) {
				System.out.println(db+(i+1)+db2);
				System.out.println(db3+(i+1)+";");
			}
	}
	public static void main(String[] args) throws Exception {
		String dir = "F:\\exchtest\\app\\turbo1";
		for (int i = 0; i < 39; i++) {
			FileUtil.copyDirectory(new File(dir), new File("F:\\exchtest\\app\\turbo"+(i+2)));
		}
	}
	public static void main4(String[] args) throws Exception, TemplateException {
		String app_file = CreateConf.class.getResource("app.properties").getFile();
		String jdbc_file = CreateConf.class.getResource("jdbc.properties").getFile();
		for (int i = 0; i < 40; i++) {
			Map<String, String> appFileMap = new HashMap<String, String>();
			appFileMap.put("embftpPort", (2000+i)+"");
			String fileApp = FreemarkerUtil.flushData(app_file, appFileMap);
			FileUtil.writeStringToFile(new File("F:\\exchtest\\app\\turbo"+(i+1)+"\\WEB-INF\\classes\\app.properties"), fileApp);
			
			Map<String, String> jdbcFileMap = new HashMap<String, String>();
			appFileMap.put("jdbcUsername", "turbo"+i);
			String fileJdbc = FreemarkerUtil.flushData(jdbc_file, jdbcFileMap);
			FileUtil.writeStringToFile(new File("F:\\exchtest\\app\\turbo"+(i+1)+"\\WEB-INF\\classes\\jdbc.properties"), fileJdbc);
		}
		
	}
	
}
